<template>
    <div id="yoso">
      <el-button plain @click="toAdd">增加</el-button>
      <el-table :data="photos" style="width: 100%">
        <el-table-column prop="p_id" label="序号" width="180"></el-table-column>
        <el-table-column label="图片" width="180">
          <template scope="scope">
            <img :src="scope.row.p_path" :alt="scope.row.p_id" :title="scope.row.p_id" width="200px">
          </template>
        </el-table-column>
        <el-table-column>
          <template scope="scope">
            <el-button type="primary" icon="el-icon-edit" circle @click="toUpdate(scope.row.p_id)"></el-button>
            <el-button type="danger" icon="el-icon-delete" circle @click="del(scope.row.p_id)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
</template>

<script>
    export default {
        name: "Photo",
      data(){
          return{
            photos:[]
          }
      },
      methods:{
        toAdd(){
          this.$router.push('/lunbo/photoAdd')
        },
        toUpdate(p_id){
          this.$router.push('/lunbo/photoUpdate/'+p_id)

        },
        paging(){
          this.$axios.get('/PhotoServlet/findAll')
            .then(resp=>{
              this.photos = resp.data;
            })
        },
        del(p_id){
          this.$axios.get('/PhotoServlet/del?p_id='+p_id).then(resp=>{
            this.paging();
          })
        }
      },
      created() {
        this.paging();
      }
    }
</script>

<style scoped>

</style>
